/**
 * chinagoods.com
 * Copyright (c) 2020-2024 All Rights Reserved.
 */
package com.ruoyi.web.controller.bot;

import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;
import org.telegram.telegrambots.meta.TelegramBotsApi;
import org.telegram.telegrambots.meta.api.methods.send.SendMessage;
import org.telegram.telegrambots.updatesreceivers.DefaultBotSession;

import javax.annotation.PostConstruct;

/**
 * @author yangpeng
 * Created by on 2024-04-17 16:28
 */
@Component
@Slf4j
public class StartBot {


    @PostConstruct
    public void start() {
        log.info("进入回调方法.....................");
        try {

            YpTestBot ypTestBot = new YpTestBot();
            TelegramBotsApi telegramBotsApi = new TelegramBotsApi(DefaultBotSession.class);
            telegramBotsApi.registerBot(ypTestBot);
            SendMessage response = new SendMessage();
            response.setDisableNotification(false);
            response.setChatId("-4155567216");
            response.setText(ypTestBot.getBotUsername() + "启动成功");
            ypTestBot.executeAsync(response);
        } catch (Exception e) {
            log.info("错误信息为：", e.getMessage());
            // throw new RuntimeException(e);
        }

    }

}